<template>
	<view :class="[`${PREFIX}`]" @click="toDetail">
		<view :class="[`${PREFIX}-head`]">
			<view :class="[`${PREFIX}-head-left`]">
				<image :class="[`${PREFIX}-head-left-avatar`]" src="" mode=""></image>
				<view :class="[`${PREFIX}-head-left-text`]">
					<view :class="[`${PREFIX}-head-left-text-name`]">子墨</view>
					<view :class="[`${PREFIX}-head-left-text-time`]">5小时前</view>
				</view>
			</view>
			<image :class="[`${PREFIX}-head-right`]" src="/static/home/more.png" mode="" @click.stop="dotClick"></image>
		</view>

		<view :class="[`${PREFIX}-content`]">
			诸事顺利
		</view>
		<view :class="[`${PREFIX}-imgs`,`${PREFIX}-imgs${imgList.length>=3?3:imgList.length}`]">
			<image :class="[`${PREFIX}-imgs-imgItem`]" @click="preview" :src="item" mode=""
				v-for="(item,index) in imgList" :key="index">
			</image>
		</view>
		<!-- 点赞跟评价 -->
		<view :class="[`${PREFIX}-rr`]">
			<view :class="[`${PREFIX}-rr-item`]" @click.stop="like">
				<!-- <image src="/static/home/like.png" mode=""></image> -->
				<image src="/static/home/like1.png" mode=""></image>
				12
			</view>
			<view :class="[`${PREFIX}-rr-item`]" @click.stop="comment">
				<image src="/static/home/comment.png" mode=""></image>
				12
			</view>
		</view>
		<u-action-sheet :actions="list" :show="show" round="10" cancelText="取消" @close="close"
			@select="select"></u-action-sheet>
		<!-- @close="close" @open="open" -->
		<!-- 只有app支持 -->
		<u-popup :show="showPopUp" closeable @close="closePopUp">
			<view :class="[`${PREFIX}-popUp`]">
				<view :class="[`${PREFIX}-popUp-title`]">分享给朋友</view>
				<view :class="[`${PREFIX}-popUp-con`]">
					<view :class="[`${PREFIX}-popUp-con-item`]" v-for="(item,index) in shareList" @click="share(item)">
						<image :src="item.imgUrl" mode=""></image>
						<view class="">{{ item.name }}</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const PREFIX = 'home-card'
	export default {
		data() {
			return {
				PREFIX,
				imgList: [require('../../../assets/icon/arrow-left-bold.png'), require(
					'../../../assets/icon/arrow-left-bold.png'), require(
					'../../../assets/icon/arrow-left-bold.png'), require(
					'../../../assets/icon/arrow-left-bold.png'), require(
					'../../../assets/icon/arrow-left-bold.png'), require(
					'../../../assets/icon/arrow-left-bold.png')], //3,4,5,6
				list: [{
					name: '举报',
					id: 0
				}],
				show: false,
				showPopUp: false,
				shareList: [{
					    imgUrl: require('../../../static/home/share1.png'),
						name: '微信好友',
						scene: 'WXSceneSession'
					},
					{
						imgUrl: require('../../../static/home/share2.png'),
						name: '朋友圈',
						scene: 'WXSceneTimeline'
					}
				]
			}
		},
		props: {
			obj: {
				type: Object,
				default: () => ({
					name: '子墨',
					time: '5小时前',
					con: '诸事顺利',
					imgList: [1, 2, 3, 4, 5, 6]
				})
			},
			isPreview: {
				type: Boolean,
				default: false
			}
		},
		created() {
			this.initList()
		},
		methods: {
			initList() {
				// #ifdef APP-PLUS
				const obj = {
					name: '分享',
					id: 1
				}
				this.list.push(obj)
				// #endif
			},
			toDetail() {
				this.$emit('toDetail')
			},
			preview() {
				if (!this.isPreview) {
					return
				}
				console.log('preview');
				uni.previewImage({
					urls: this.imgList
				})
			},
			like() {
				console.log('点赞');
			},
			comment() {
				console.log('comment');
			},
			dotClick() {
				this.show = true
				console.log('xxxxxxxxxxx');
			},
			close() {
				this.show = false
			},
			select(val) {
				if (val.id === 0) { // 举报
					uni.navigateTo({
						url: '/pages/home/report'
					})
				}
				if (val.id === 1) { // 分享
					this.showPopUp = true
				}
			},
			closePopUp() {
				this.showPopUp = false
			},
			share(val) {
				uni.getProvider({
					service: "share",
					success: (res) => {
						console.log(res);
						uni.share({
							provider: "weixin",
							title: '',
							scene: val.scene,
							href:"sdfsdfd",
							imageUrl:"sdfds",
							success: () => {
								console.log('success');
								// uni.showToast({
								// 	title: '分享成功'
								// })
							},
							fail: (err)=>{
								console.log('err============');
								console.log(err);
							}
						})
					}
				})
			}
		}
	}
</script>

<style lang="less">
	.home-card {
		background: #fff;

		&-head {
			height: 140rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 40rpx;

			&-left {
				display: flex;
				align-items: center;

				&-avatar {
					width: 60rpx;
					height: 60rpx;
					background: blue;
					border-radius: 50%;
					margin-right: 34rpx;
				}

				&-text {
					&-name {
						height: 34rpx;
						font-size: 36rpx;
						color: #333333;
					}

					&-time {
						color: #999999;
						text-align: left;
						font-size: 30rpx;
						margin-top: 14rpx;
					}
				}
			}

			&-right {
				width: 120rpx;
				height: 141rpx;
			}
		}

		&-content {
			padding: 26rpx 40rpx;
			box-sizing: border-box;
			color: #333333;
			font-size: 36rpx;
			font-weight: 0;
		}

		&-imgs {
			box-sizing: border-box;
			padding: 0 40rpx 16rpx 40rpx;
			display: flex;
		}

		&-imgs1 {
			margin-bottom: 8rpx;

			image {
				width: 480rpx;
				height: 332rpx;
				border-radius: 20rpx;
				background: #cecece;
			}
		}

		&-imgs2 {
			display: flex;
			justify-content: space-between;
			margin-bottom: 8rpx;

			image {
				width: 326rpx;
				height: 324rpx;
				border-radius: 20rpx;
				background: #cecece;
			}
		}

		&-imgs3 {
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			image {
				width: 218rpx;
				height: 216rpx;
				border-radius: 20rpx;
				background: #cecece;
				margin-bottom: 8rpx;
			}
		}

		&-rr {
			height: 94rpx;
			display: flex;

			&-item {
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;

				image {
					width: 48rpx;
					height: 48rpx;
				}
			}
		}

		&-popUp {
			&-title {
				height: 50rpx;
				font-size: 36rpx;
				line-height: 50rpx;
				color: #999;
				padding-left: 53rpx;
				padding-top: 36rpx;
			}

			&-con {
				display: flex;
				padding: 54rpx 0 80rpx 0;

				&-item {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					image {
						width: 64rpx;
						height: 64rpx;
						margin-bottom: 20rpx;
					}
				}
			}
		}
	}
</style>